class Solution {
    public String reverseStr(String s, int k) {
        if (s.length() <= 1 || k == 1) return s;
        char[] chars = s.toCharArray();
        for (int i = 0; i < chars.length; i += 2*k) {
            for (int l = i, r = Math.min(i + k - 1, chars.length - 1); l < r; l++, r--) {
                char tmp = chars[l];
                chars[l] = chars[r];
                chars[r] = tmp;
            }
        }
        return new String(chars);
    }
}
